package com.hhxy.practice;

import java.util.Scanner;
//计算最终评分
public class CalculateScore {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您打的分数：");
        double[] arr = new double[5];
        for (int i = 0; i <5 ; i++) {
            System.out.println("请输入第"+(i+1)+"个评委打的分：");
            arr[i] = sc.nextDouble();
        }
        System.out.println("最终得分为："+calculateScore(arr));



    }
    //计算分数的方法
    private static double calculateScore(double[] arr) {
        double min=100,max=-1,sum =0;
        for (int i = 0; i <arr.length ; i++) {
            if(arr[i]<min){
                min = arr[i];
            }
            if(arr[i]>max){
                max = arr[i];
            }
            sum += arr[i];
        }
        return (sum-min-max)/(arr.length-2);
    }
}
